<script language="javascript" type="text/javascript" src="../admin/p_noticia/valida_form.js"></script>
<?php 
include "../admin/p_usuario/valida_credenciais.php";
$valCr = new valida_credenciais();
//$nivel define o array de acessos, ou seja, os grupos que podem acessar essa pagina

/*$nivel = array(1,2,3);
if(!($valCr->validar($nivel))){
	header('Location: index.php?pg=denied');
}*/

$id = $_GET['i'];
$resul = mysql_query("SELECT * FROM `noticias` WHERE `noticias`.`id_noticia` = $id");
$noticia = mysql_fetch_array($resul);

$resultado = mysql_query("SELECT * FROM `categoria_noticia` WHERE `categoria_noticia`.`id_categoria_noticia` = {$noticia['categoria_noticia_id']}");
$cat_noticia = mysql_fetch_array($resultado);

?>
<div class="form">
	<div class="row">
		<div class="col-md-12">
			<div class="page-header">
				<h2>Editar dados da Not&iacutecia</h2>
			</div>
		</div>
	</div>
	<div class="row">
	<div class="col-md-3">
		<?php include "../admin/p_noticia/actions-noticia.php"; ?>
		
		</div><!-- end col md 3 -->
		<div class="col-md-9">
		<!-- HEAD DE FORMULÃ�RIO -->
		<div class="panel panel-default">
			<div class="panel-heading"><h5>Formul&aacuterio para editar informa&ccedil&otildees da Not&iacutecia</h5></div>
			<div class="panel-body">
			<!-- FORMULÃ�RIO -->
			<form  method="post" name="form1" action="../admin/p_noticia/editar.php" enctype="multipart/form-data">
				<div class="row">
					<div class="col-md-12 form-group"><h6>(<span class="text-danger">*</span>) Campos de preenchimento obrigat&oacuterio.</h6></div>
				</div>
				<input type="hidden" name="idnoticia" value="<?php echo $noticia['id_noticia'];?>">
				
				<div class="row">
					<div class="form-group col-md-12">
						<label for="titulo">T&iacutetulo: (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" name="titulo" id="titulo" value="<?php echo $noticia['titulo'];?>">
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-8">
						<label for="categoria">Categoria da Not&iacutecia (<span class="text-danger">*</span>)</label>
    					<select name="categoria" id="categoria" class="form-control">
		          			<option value='selecione'>Selecione...</option>
							<?php
								$query = mysql_query("SELECT `id_categoria_noticia`, `descricao_categoria_noticia`, `status` FROM `categoria_noticia` WHERE `status` LIKE '1'");
								while($lista = mysql_fetch_array($query)) { 
									if($lista['id_categoria_noticia'] == $cat_noticia['id_categoria_noticia']){?> 
										<option value="<?php echo $lista['id_categoria_noticia']; ?>" selected><?php echo $lista['descricao_categoria_noticia']; ?></option>
									<?php }else{?>
										<option value="<?php echo $lista['id_categoria_noticia']; ?>"><?php echo $lista['descricao_categoria_noticia']; ?></option>
							<?php 
									}
								}?>
			          	</select>
					</div>
					<div class="form-group col-md-4">
						<label for="status">Situa&ccedil&atildeo (<span class="text-danger">*</span>)</label>
    					<select name="status" id="status" class="form-control">
		          			<option value='selecione'>Selecione...</option>
		          			<?php if($noticia['status'] == 1){ ?>
								<option value="<?php echo $noticia['status']; ?>" selected>Not&iacutecia Ativa</option>
								<option value="0">Not&iacutecias Inativa</option>
							<?php } else{?>
								<option value="<?php echo $noticia['status']; ?>" selected>Not&iacutecia Inativa</option>
								<option value="1">Not&iacutecia Ativa</option>
							<?php }?>
		          		</select>
		          	</div>
				</div>
				<div class="row">
					<div class="form-group col-md-12">
						<label for="NoticiaConteudo">Conte&uacutedo:  (<span class="text-danger">*</span>)</label>
    					<script type="text/javascript">
							var ckeditor = CKEDITOR.replace( 'NoticiaConteudo' );
						</script>
						<textarea name="NoticiaConteudo" class="ckeditor" cols="42" rows="15" ><?php echo $noticia['conteudo'];?></textarea>
					</div>					
				</div>
				
				<br>
				<div class="row">
					<div class="form-group col-md-2">
						<input type="submit" value="Salvar" class="btn btn-default" name="enviar" onclick="return valida()" >
					</div>
				</div>
			</form>
			</div>
		</div>

		</div><!-- end col md 12 -->
	</div><!-- end row -->
</div>
			